<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : view.jsp
    Description : 이벤트 상세 내역을 보여준다.
    author jkKim
    since 2012. 5. 10.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 5. 10.     jkKim     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/com/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/com/include/doctype.jspf" %>
<script type="text/javascript" src="/kr/common/js/ajaxupload.js"></script>
<script>
function openLayer1(evntMnSn){
    $.ajax({
        type: "GET",
        dataType : "text",
        url: "<c:url value='/evnt/evntWnrLayer.do'/>",
        data: { 
            'evntMnSn' : evntMnSn
        },
        success: function(data){
            if(data){
                $("#layerpopup-winnerpopup").html('');
                $("#layerpopup-winnerpopup").append(data);
                $('body').dimmedFrame();
                $("#winnerpopup").css({top:$(window).scrollTop()+250}).show();
            }
        }
    });
}

function closeLayer1(){
    $('.dimmed-frame').remove();
    $("#winnerpopup").hide(); 
}

function checkWinner(evntMnSn){
    var hpNo1 = $("#hpNo1");
    var hpNo2 = $("#hpNo2");
    var hpNo3 = $("#hpNo3");
    var mbrNm = $("#mbrNm");
    
    if(hpNo2.val() == "" || hpNo2.val().length<3){
        alert("전화번호를 입력해 주세요.");
        hpNo2.focus();
        return;
    }
    if(hpNo3.val() == "" || hpNo3.val().length<4){
        alert("전화번호를 입력해 주세요.");
        hpNo3.focus();
        return;
    }
    
    if(mbrNm.val() == ""){
        alert("성명을 입력해 주세요.");
        mbrNm.focus();
        return;
    }
    var ptcChidHpNo = hpNo1.val()+hpNo2.val()+hpNo3.val();
    var ptcChidNm = mbrNm.val();
    
    
    $.ajax({
        type: "POST",
        dataType : "xml",
        url: "<c:url value='/evnt/selectEvntWnrDetail.do'/>",
        data: { 
            'evntMnSn' : evntMnSn,
            'ptcChidHpNo' : ptcChidHpNo,
            'ptcChidNm' : ptcChidNm
        },
        success: function(data){
            var result={};
            var items = $(data).find("item");
            items.each(function(index,element){
               var name = $(this).find("name").text();
               var value = $(this).find("value").text();
               result[name] = value;
            });
            if(result["result"] =="OK"){
                $.ajax({
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntWnrMemoLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn,
                        'winCd' : result["value"]
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }
                            
                            $("#winnerpopup02").show();
                        }
                    }
                });
            }else{
                $.ajax({ 
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntFailLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn 
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }
                            
                            $("#winnerpopup02").show();
                        }
                    }
                });
                
            }
        }
    });
    
}

function evntPrint(id) {
    $('#'+id).printArea({mode: 'popup', popupClose: false});

    return false;
}


 
</script>
</head>
<body>
<!-- 당첨자 발표 -->
<div id="winnerpopup" class="layerpopup winnerpopup"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //당첨자 발표 -->

<!-- 당첨자 발표2 -->
<div id="winnerpopup02" class="layerpopup winnerpopup02"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup2">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //당첨자 발표2 -->
<form method="get" action="<c:url value='/evnt/selectEvntMnPaging.do'/>" name="serchForm" id="serchForm" onsubmit="return false">
<input type="hidden" name="pageIndex" id="pageIndex" value="${evntMnSearchVO.pageIndex}">
</form>
<!-- 개인정보입력 -->
<div id="personinfopopup" class="layerpopup personinfopopup"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_person_info02.gif" alt="개인정보 수집, 이용에 관한 안내" /></h1>
    </div>
    <div class="collect-wrap02">
        <div class="rule"><div class="inner"> 
        </div></div>
        <p class="collect-notice"><img src="/kr/images/layerpopup/txt_person_info09.gif" alt="이벤트 응모 사항에 한하여 이메일/휴대전화 수신거부는 수신허용으로 간주됩니다" /></p>
        <div class="etc-function">
            <label><input type="checkbox" class="check" id="insertUserCheck"/> 위의 사실에 숙지하였으며, 정보이용에 동의합니다.</label>
        </div>
    </div>
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_person_info.gif" alt="개인정보입력" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_person_info_desc.gif" alt="이벤트 응모 및 경품 수령 등을 위한 고객님의 정확한 정보를 확인, 입력해 주세요." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-evnt">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //개인정보입력 -->
<div id="wrap" class="non-subnavigation">
    <%@ include file="/WEB-INF/jsp/com/include/navi_utill_sub.jspf" %>
    <%@ include file="/WEB-INF/jsp/com/include/navi_header.jspf" %> 
    <hr />
   
    <%@ include file="/WEB-INF/jsp/com/include/sub_header_event02.jspf" %> 
    <hr />
    <input type="hidden" id="event_code" value="${result.evntMnSn }"/>
    <input type="hidden" id="event_name" value="${result.evntTitl }"/>
    <div id="container">
        <div id="subtitle-area"><div class="subtitle-area-inner">
            <%@ include file="/WEB-INF/jsp/com/include/location.jspf" %>
        </div></div>
        <div id="article">
            <p class="default-desc"><img src="/kr/images/event/txt_event02_01.gif" alt="지난 이벤트 조회 및 당첨여부를 확인하실 수 있습니다." /></p>
            <form action="" id="evntAsw">
                <input type="hidden" id="evntMnSn" value="${result.evntMnSn }"/>
                <input type="hidden" id="evntPtcChidSn" value=""/>
                <input type="hidden" id="evntType" value="${result.evntType}"/>
                <input type="hidden" id="userInfo" value="${userInfo.mbrNm}"/>
                <c:if test="${evntPtcChidVO == null}">
                    <input type="hidden" id="evntPtcChidVO" value=""/>
                </c:if>
                <c:if test="${evntPtcChidVO != null}">
                    <input type="hidden" id="evntPtcChidVO" value="${evntPtcChidVO.evntPtcChidSn}"/>
                </c:if>
            </form>
            <c:if test="${result.evntType == 'E4'}">
                ${result.dtlImg}
            </c:if>
            <c:if test="${result.evntType == 'E1'}">
                ${result.dtlImg}
            </c:if>
            <c:if test="${result.evntType == 'E2'}">
                ${result.dtlImg}
            <div class="reply-wrap">
                <jsp:scriptlet>
                        pageContext.setAttribute("crlf", "\r\n");
                        pageContext.setAttribute("lf", "\n");
                        pageContext.setAttribute("cr", "\r");
                </jsp:scriptlet>  
                <div class="reply-list-wrap">
                    <div class="section">
                    <c:if test="${evntPtcChidVO != null}">    
                        <c:if test="${evntPtcChidVO.ptChidImgPath == null}">
                            <img src="/kr/temp/@none_50x50.jpg" alt="참여고객 이미지" class="thumb" />
                        </c:if>
                        <c:if test="${evntPtcChidVO.ptChidImgPath != null}">
                            <img src="${evntPtcChidVO.ptChidImgPath}" alt="참여고객 이미지" class="thumb" />
                        </c:if>
                            
                        <div class="user-area">
                            <strong class="name">${evntPtcChidVO.ptcChidNm }</strong>
                            <p class="text-area">${fn:replace(evntPtcChidVO.reb, lf, "<br/>")}</p>
                            <em class="date"><fmt:formatDate value="${evntPtcChidVO.rgstDtm}" pattern="hh:mm:ss, yyyy/MM/dd" /></em>
                            <img src="/kr/images/common/button/btn_delete.gif" alt="댓글삭제" class="delete" />
                        </div>
                    </c:if>
                    </div>
                    <c:forEach var="vo" items="${resultList}" varStatus="status">
                        <div class="section">
                            <c:if test="${vo.ptChidImgPath == null}">
                                <img src="/kr/temp/@none_50x50.jpg" alt="참여고객 이미지" class="thumb" />
                            </c:if>
                            <c:if test="${vo.ptChidImgPath != null}">
                                <img src="${vo.ptChidImgPath}" alt="참여고객 이미지" class="thumb" />
                            </c:if>
                                
                            <div class="user-area">
                                <strong class="name">${vo.ptcChidNm }</strong>
                                <p class="text-area">${fn:replace(vo.reb, lf, "<br/>")}</p>
                                <em class="date"><fmt:formatDate value="${vo.rgstDtm}" pattern="hh:mm:ss, yyyy/MM/dd" /></em>
                                <!-- a href="#"><img src="/kr/images/common/button/btn_delete.gif" alt="댓글삭제" class="delete" /></a-->
                            </div>
                        </div>
                    </c:forEach>
                </div>
                <c:if test="${paginationInfo.totalRecordCount >= 0 }">
                    <div class="paging">
                        <able:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="fnLinkPage" />
                    </div>
                </c:if>
            </div>
            </c:if>
            
            <c:if test="${result.evntType == 'E3'}">
            ${result.dtlImg}
            <div class="survey-wrap">
                <c:forEach var="vo" items="${resultList}" varStatus="status">
                    <div class="section">
                        <input type="hidden" name="num" value="${status.count }">
                        <input type="hidden" name="qustK" value="${vo.qustK}">
                        <input type="hidden" name="evntIsvyMnSn" value="${vo.evntIsvyMnSn }">
                        <input type="hidden" name="choiPsblIct" value="${vo.choiPsblIct }">
                        
                    <c:if test="${vo.qustK == 'Q1'}"><!-- 객관식 -->
                        <c:if test="${vo.choiPsblIct == 1}">
                            <p class="choose">${status.count }. ${vo.qustTitl }</p>
                            <c:if test="${vo.scrnLoc == 0}">
                                <ul class="row-type">
                                    <c:forEach var="voResult" items="${vo.evntIsvyVOList}" varStatus="statusVo">
                                        <li><label><input type="radio" class="check" name="E${vo.evntIsvyMnSn }" value="${voResult.evntIsvySn }" rspYn="${voResult.rspYn }" /> ${voResult.sbc }</label></li>
                                    </c:forEach>
                                </ul> 
                            </c:if> 
                           
                            <c:if test="${vo.scrnLoc == 1}">
                                <div class="col-type">
                                    <c:forEach var="voResult" items="${vo.evntIsvyVOList}" varStatus="statusVo">
                                    <c:if test="${statusVo.count == 1}">
                                        <label><input type="radio" class="check" name="E${vo.evntIsvyMnSn }" value="${voResult.evntIsvySn }" rspYn="${voResult.rspYn }" /> ${voResult.sbc }</label>
                                    </c:if>
                                    <c:if test="${statusVo.count > 1}">
                                        <label><input type="radio" class="check space" name="E${vo.evntIsvyMnSn }" value="${voResult.evntIsvySn }" rspYn="${voResult.rspYn }" /> ${voResult.sbc }</label>
                                    </c:if>
                                    </c:forEach>
                                </div> 
                            </c:if>
                        </c:if>
                        <c:if test="${vo.choiPsblIct != 1}">
                            <p class="choose">${status.count }. ${vo.qustTitl }</p>
                            <c:if test="${vo.scrnLoc == 0}">
                                <ul class="row-type">
                                    <c:forEach var="voResult" items="${vo.evntIsvyVOList}" varStatus="statusVo">
                                        <li><label><input type="checkbox" class="check" name="E${vo.evntIsvyMnSn }" value="${voResult.evntIsvySn }" rspYn="${voResult.rspYn }"/> ${voResult.sbc }</label></li>
                                    </c:forEach>
                                </ul> 
                            </c:if>
                            <c:if test="${vo.scrnLoc == 1}">
                                <div class="col-type">
                                    <c:forEach var="voResult" items="${vo.evntIsvyVOList}" varStatus="statusVo">
                                    <c:if test="${statusVo.count == 1}">
                                        <label><input type="checkbox" class="check" name="E${vo.evntIsvyMnSn }" value="${voResult.evntIsvySn }" rspYn="${voResult.rspYn }"/> ${voResult.sbc }</label>
                                    </c:if>
                                    <c:if test="${statusVo.count > 1}">
                                        <label><input type="checkbox" class="check space" name="E${vo.evntIsvyMnSn }" value="${voResult.evntIsvySn }" rspYn="${voResult.rspYn }"/> ${voResult.sbc }</label>
                                    </c:if>
                                    </c:forEach>
                                </div> 
                            </c:if>
                                                           
                        </c:if>
                    
                    </c:if>
                    <c:if test="${vo.qustK == 'Q2'}"><!-- 차수선택 -->
                        <p class="choose">${status.count }. ${vo.qustTitl }</p>
                        <div class="col-type">
                            <select class="select select-type1" style="width:190px;" name="E${vo.evntIsvyMnSn}">
                                <c:forEach var="voResult" items="${vo.evntIsvyVOList}" varStatus="statusvo">
                                    <option value="${voResult.evntIsvySn}">${voResult.sbc}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </c:if>
                    <c:if test="${vo.qustK == 'Q3'}"><!-- 파일업로드 -->
                        <p class="choose">${status.count }. ${vo.qustTitl }</p>
                        <div class="col-type">
                            <input type="hidden" value="" name="E${vo.evntIsvyMnSn }" id="E${vo.evntIsvyMnSn }"/>
                            <input type="text" class="txt" style="width:215px;" title="${vo.qustTitl }" name="UP${vo.evntIsvyMnSn }" id="UP${vo.evntIsvyMnSn }" readonly="readonly"/>
                            <input type="image" src="/kr/images/common/button/btn_search.gif" alt="SEARCH"  id="EB${vo.evntIsvyMnSn }"/>
                            <p class="tip">- ${vo.upldPsblFil } 파일 형식만 가능합니다.</p>
                            <p class="tip">${vo.qustSbc}</p>
                        </div>
                        <script>
                        option.fileReturnValue ='E${vo.evntIsvyMnSn}';
                        option.fileExt="${vo.upldPsblFil }";
                        option.name='EFB${vo.evntIsvyMnSn }';
                        option.fileNameValue='UP${vo.evntIsvyMnSn }';
                        //파일 업로드 객체 추가
                        var uploadFile  = new AjaxUpload("EB${vo.evntIsvyMnSn }", option);
                        //uploadFiles["U${vo.evntIsvyMnSn}"] = uploadFile;
                        uploadFiles.push(uploadFile);
                        </script>
                    </c:if>
                    <c:if test="${vo.qustK == 'Q4'}"><!-- 주관식 -->
                        <p class="choose">${status.count }. ${vo.qustTitl }</p>
                        <div class="col-type">
                            <input type="text" class="txt" style="width:635px;" name="E${vo.evntIsvyMnSn }" title="" maxlength="100"/>
                        </div>
                    </c:if>
                    </div>
                </c:forEach>    
            </div>            
            </c:if> 
            <c:if test="${result.st == 'S' && result.evntType != 'E4'}">
                <div class="btnwrap">
                    <a href="javascript:openLayer1('${result.evntMnSn}');"><img src="/kr/images/common/button/btn_winner_view02.gif" alt="당첨자 보기"></a>
                </div>
            </c:if>
        </div>
    </div>
    <hr />
    <%@ include file="/WEB-INF/jsp/com/include/footer.jspf" %>